package k3_IO.p2_fileStream.demo04;

import k3_IO.p2_fileStream.demo01.Employee;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class WriteMoreObject {
    public static void main(String[] args) throws Exception {

        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("E://emp.txt"));

        ArrayList<Employee> emps = new ArrayList<>();
        emps.add(new Employee("tom","哈尔滨",10));
        emps.add(new Employee("jerry","北京",20));
        emps.add(new Employee("kitty","上海",30));

        oos.writeObject(emps);

        oos.close();

        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("E://emp.txt"));
        ArrayList<Employee> empsReceive = (ArrayList<Employee>) ois.readObject();

        System.out.println(empsReceive);

        ois.close();

    }
}
